// Decompiled by DJ v3.11.11.95 Copyright 2009 Atanas Neshkov  Date: 2009/9/10 11:00:58
// Home Page: http://members.fortunecity.com/neshkov/dj.html  http://www.neshkov.com/dj.html - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   FindInJar.java

import java.io.File;
import java.io.PrintStream;
import java.util.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

public class FindInJar
{

    public FindInJar()
    {
        jarFiles = new ArrayList();
    }

    public FindInJar(String s)
    {
        jarFiles = new ArrayList();
        className = s;
    }

    public void setClassName(String s)
    {
        className = s;
    }

    public List findClass(String s, boolean flag)
    {
        searchDir(s, flag);
        return jarFiles;
    }

    protected void searchDir(String s, boolean flag)
    {
        File file;
        file = new File(s);
        if(!file.isDirectory())
            return;
        try
        {
            File afile[] = file.listFiles();
            for(int i = 0; i < afile.length; i++)
                if(flag && afile[i].isDirectory())
                {
                    searchDir(afile[i].getAbsolutePath(), true);
                } else
                {
                    String s1 = afile[i].getAbsolutePath();
                    if(s1.endsWith(".jar") || s1.endsWith(".zip"))
                    {
                        ZipFile zipfile = new ZipFile(s1);
                        Enumeration enumeration = zipfile.entries();
                        do
                        {
                            if(!enumeration.hasMoreElements())
                                break;
                            ZipEntry zipentry = (ZipEntry)enumeration.nextElement();
                            String s2 = getClassName(zipentry);
                            if(s2.equals(className) || s2.equals((new StringBuilder()).append(className).append(".class").toString()))
                                jarFiles.add(s1);
                        } while(true);
                    }
                }

        }
        catch(Exception exception)
        {
            exception.printStackTrace();
        }
        return;
    }

    public List getFilenames()
    {
        return jarFiles;
    }

    protected String getClassName(ZipEntry zipentry)
    {
        StringBuffer stringbuffer = new StringBuffer(zipentry.getName().replace('/', '.'));
        return stringbuffer.toString();
    }

    public static void main(String args[])
    {
        System.out.println((new StringBuilder()).append("find [").append(args[1]).append("in directory [").append(args[0]).append("]").toString());
        FindInJar findinjar = new FindInJar(args[1]);
        List list = findinjar.findClass(args[0], true);
        if(list.size() == 0)
        {
            System.out.println((new StringBuilder()).append("Not Found in ").append(args[0]).toString());
        } else
        {
            for(int i = 0; i < list.size(); i++)
                System.out.println(list.get(i));

        }
    }

    public String className;
    public ArrayList jarFiles;
}
